{% extends 'att/report/base.html' %} {% load i18n %} {% block extra_search_field %}
{% endblock %} {% block extra_search_field_submit %} var vacationtime = $("#{{ model_name }}-search-form select[name='vacationtime']").val(); var vacationyear = $("#{{ model_name }}-search-form input[name='vacationyear']").val(); c["vacationtime"] = vacationtime; c["vacationyear"] = vacationyear; var select_year = $("input[name='vacationyear']").val(); var myDate = new Date(); if(myDate.getFullYear()==select_year){ c["start_date"] = select_year+'-01-01'; c["end_date"] = myDate.getFullYear().toString() + '-'+ (myDate.getMonth()+1).toString() + '-'+ myDate.getDate().toString(); }else{ c["start_date"] = select_year+'-01-01'; c["end_date"] = select_year+'-12-31'; } {% endblock %} {% block search_form_init %} var cur = moment(new Date()); var startDate = laydate.render({ elem: '#{{ model_name }}-start-date', type: 'date', value: cur.startOf('month').format('YYYY-MM-DD'), done: function (value, date) { endDate.config.min = { year: date.year, month: date.month - 1, date: date.date }; } }); laydate.render({ elem: '#{{ model_name }}_vacationyear' ,type: 'year' ,value: cur.endOf('year').format('YYYY'), }); var endDate = laydate.render({ elem: '#{{ model_name }}-end-date', type: 'date', value: cur.endOf('month').format('YYYY-MM-DD'), done: function (value, date) { startDate.config.max = { year: date.year, month: date.month - 1, date: date.date }; } }); $.extend(opts, {where: {start_date: cur.startOf('month').format('YYYY-MM-DD'), end_date: cur.endOf('month').format('YYYY-MM-DD')}}); $('#{{ model_name }}-start-date').parent().parent().hide(); $('#{{ model_name }}-end-date').parent().parent().hide(); $('#{{ model_name }}_search_timetable').hide(); if("{{ user.is_superuser }}" == "False" && "{{ user.auth_company }}" !="None") { var company = "{{ user.auth_company.id }}"; }else{ var company = ''; } $.ajax({ url: "/att/api/vacationtime/?company=" + company , dataType: 'json' , type: "GET" , success: function (response) { var data = response.data; var options = ''; data.forEach(function (item) { options += ''; }); $("#{{ model_name }}_vacationtime").html(options); form.render('select'); } , error: function (XMLHttpRequest, textStatus, errorThrown) { console.log(XMLHttpRequest.status); } }); {% endblock %} {% block opts_modify %} var userCols = [ {field:'emp_code', width:120, title: "{% trans 'report_column_empCode' %}", sort:true, fixed: 'left'} ,{field:'first_name', title: "{% trans 'report_column_firstName' %}", fixed: 'left', width: 100} ,{field:'last_name', title: "{% trans 'report_column_lastName' %}", fixed: 'left', hide: true} ,{field:'nick_name', title: "{% trans 'report_column_nickName' %}", fixed: 'left', hide: true} ,{field:'gender', title: "{% trans 'report_column_gender' %}", fixed: 'left', hide: true} ,{field:'dept_code', title: "{% trans 'report_column_departmentCode' %}", fixed: 'left', width: 100} ,{field:'dept_name', width:140, title: "{% trans 'report_column_departmentName' %}", fixed: 'left', width: 100} ,{field:'position_code', title: "{% trans 'report_column_positionCode' %}", hide: true} ,{field:'position_name', title: "{% trans 'report_column_positionName' %}", hide: true} ,{field:'vacation_rule', title: "{% trans 'report_column_vacationRule' %}"} ,{field:'hire_date', title: "{% trans 'report_column_hireDate' %}"} ,{field:'seniority', title: "{% trans 'report_column_seniority' %}"} ,{field:'taken_previous_period', title: "{% trans 'report_column_takenPreviousPeriod' %}"} ,{field:'taken_actual_period', title: "{% trans 'report_column_takenActualPeriod' %}"} ,{field:'total_taken', title: "{% trans 'report_column_totalTaken' %}", templet: function(obj){ return obj.taken_previous_period + obj.taken_actual_period; }} ,{field:'vacation_left', title: "{% trans 'report_column_vacationLeft' %}"} ]; var _cols = []; $.extend(opts, { cols: [userCols.concat(_cols)] ,method: "get" ,url: "/att/api/vacationReport/" }); {% endblock %} {% block columns_modify %} var dateCols = []; _cols = userCols.concat(dateCols); $.extend(opts, {where: c, cols: [_cols]}) // tb = table.reload(tb.config.id, opts) tb = table.render(opts); $.extend(action_opts, { curTable: tb }); $("#{{model_name}}_fluid" + " div.grid-toolbar").actions(action_opts); form.on("submit({{ model_name }}-search)", function (data) { refreshReport(''); }); {% endblock %}